package guowenlong.golf.ui.personal.changepsaaword;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.OnClick;
import guowenlong.golf.R;
import guowenlong.golf.entity.ChangePasswordEntity;
import guowenlong.golf.ui.personal.changepsaaword.ChangePasswordContract.View;
import guowenlong.golf.widget.IOSEditText;
import me.wenlong.mixutils.mvp.BaseActivity;
import me.wenlong.mixutils.util.SpUtil;

/**
 * des   : 描述 author: Administrator email : guowenlong20000@gmail.com time  : 2017年03月08日 下午 9:27.
 */

public class ChangePasswordActivity extends
    BaseActivity<ChangePasswordPresenter, ChangePasswordModel> implements
    View {

  @BindView(R.id.tv_back)
  TextView tvBack;
  @BindView(R.id.btn_safe)
  Button btnSafe;
  @BindView(R.id.et_old_password_change)
  IOSEditText etOldPasswordChange;
  @BindView(R.id.et_password_change)
  IOSEditText etPasswordChange;
  @BindView(R.id.et_repassword_change)
  IOSEditText etRepasswordChange;

  @Override
  public void changePasswordSuccess(ChangePasswordEntity changePasswordEntity) {
    Toast.makeText(this, "密码修改成功", Toast.LENGTH_SHORT).show();
    finish();
  }

  @Override
  public void changePasswordError(ChangePasswordEntity changePasswordEntity) {
    Toast.makeText(this, changePasswordEntity.getError_message(), Toast.LENGTH_SHORT).show();
  }

  @Override
  protected int getContentView(Bundle savedInstanceState) {
    return R.layout.activity_changepassword;
  }

  @Override
  protected void initView(Bundle savedInstanceState) {

  }

  @Override
  protected void initData() {

  }

  @OnClick({R.id.tv_back, R.id.btn_safe})
  public void onClick(android.view.View view) {
    switch (view.getId()) {
      case R.id.tv_back:
        finish();
        break;
      case R.id.btn_safe:
        mPresenter.changePassword(SpUtil.getUser().getAuthToken(),
            etPasswordChange.getText().toString(), etRepasswordChange.getText().toString());
        break;
    }
  }
}